//
//  WXPKAnimationView.h
//  ParentsCommunity
//
//  Created by tianlong on 2018/5/2.
//  Copyright © 2018年 XES. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "WXPKConfig.h"
#import "WXPKAnimationAlert.h"
#import "WXPKLOTAnimationView.h"

@interface WXPKAnimationView : UIView

@property (copy, nonatomic) NSString *animationJson;
@property (copy, nonatomic) void (^clickedCloseBlock)();
@property (weak, nonatomic) UIButton *closeBtn;
@property (weak, nonatomic) UIImageView *backgroundImageView;
//@property (weak, nonatomic) id<WXPKAnimationDelegate> delegate;
@property (assign, nonatomic) BOOL isAnimating;
@property (strong, nonatomic) WXPKLOTAnimationView *playView;


- (void)play;
- (void)pause;
- (void)stop;

/**
 播放动画
 @param repeatCount 重复次数，大于等于
 @param json 动画json
 @param speed 播放速度，默认1
 @param completion 完成回调
 */
- (void)playAnimationWithJson:(NSString *)json
                        speed:(CGFloat)speed
                  repeatCount:(NSInteger)repeatCount
                   completion:(void (^)(BOOL finished))completion;
/**
 播放动画
 @param repeatCount 重复次数，大于等于
 @param json 动画json
 @param speed 播放速度，默认1
 @param playTodo 即将播放时要做的事
 @param completion 完成回调
 */
- (void)playAnimationWithJson:(NSString *)json
                        speed:(CGFloat)speed
                  repeatCount:(NSInteger)repeatCount
            willBeginPlayTodo:(void (^)(void))playTodo
                   completion:(void (^)(BOOL finished))completion;

/**
 弹框类
 @param json 动画json
 @param speed 播放速度，默认1
 @param completion 完成回调
 */
- (WXPKAnimationAlert *)showAnimationAlertWithJsonName:(NSString *)json
                                                 speed:(float)speed
                                             alertSize:(CGSize)alertSize
                                                inView:(UIView *)inView
                                            completion:(void (^)(BOOL isFinished))completion;
/**
 绑定视图到动画指定路径的图层上
 */
- (void)bindingUIView:(UIView *)view
           forKeyPath:(NSString *)keyPath
            imageName:(NSString *)imageName;

/**
 通过json获取动画中图层名称的集合
 */
- (NSDictionary *)getAnimationInfoWithJsonName:(NSString *)jsonName;

/**
 转换动画中指定元素的layer的frame到animtionView的layer上
 */
- (CGRect)convertElementLayerFrameToAnimationLayer:(CALayer *)elementLayer;

#pragma mark - 抛物线动画
- (void)throwObjectView:(UIView *)startView
                     to:(UIView *)endView
                 height:(CGFloat)height
               duration:(CGFloat)duration
             completion:(void (^)(BOOL isFinished))completion;

/**
 pk宝箱专用动画(抖动结束之后缩小)

 @param startView 抖动的json动画视图
 @param endView 缩小之后的视图(主要用来获取结束位置)
 @param height 运动轨迹的y变化
 @param duration 动画持续时间
 @param completion 结束回调
 */
- (void)throwPKBoxView:(UIView *)startView
                    to:(UIView *)endView
                height:(CGFloat)height
              duration:(CGFloat)duration
            completion:(void (^)(BOOL isFinished))completion;

@end
